#include<bits/stdc++.h> 
#define int long long 
using namespace std;
int n,q,t1,t2;
string s[200010][2];
signed main(){
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	cin>>n>>q;
	for(int i=1;i<=n;i++) cin>>s[i][0]>>s[i][1];
	for(int i=1;i<=q;i++){
		cin>>t1>>t2;
		cout<<"1\n";
	}
	return 0;
}
